package leetcode.editor.cn;

import java.util.Arrays;

/**
 * @author Administrator
 * @description 股票平滑下跌阶段的数目
 * @date 2023/3/18 0018
 */
public class Solution2110 {
    public long getDescentPeriods(int[] prices) {
        //int len = prices.length;
        //long ans = 1;
        //int[] dp = new int[len];
        //Arrays.fill(dp, 1);
        //for (int i = 1; i < len; i++) {
        //    if (prices[i-1]-prices[i] == 1){
        //        dp[i] += dp[i-1];
        //    }
        //    ans += dp[i];
        //}
        //return ans;

        long ans = 1, pre = 1;
        for (int i = 1; i < prices.length; i++) {
            if (prices[i-1]-prices[i] != 1) {
                pre = 1;
            }else {
                pre += 1;
            }
            ans += pre;
        }
        return ans;
    }
}
